<?php
/*
Module:		RSS
Version:	20071128a-DAT
File:		run.php
*/

  $RSSConfig = array();
  $RSSConfig['URLs']=array();
  $RSSConfig['Commands']=array();
  $RSSConfig['Link_ID']=array();

  $RSSConfig['URLs'][0]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/label/musik';
  $RSSConfig['Commands'][0]  = '!MUSIC';
  $RSSConfig['Link_ID'][0]   = 1;
  
  $RSSConfig['URLs'][1]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/state/com.google/broadcast';
  $RSSConfig['Commands'][1]  = '!NEWS';
  $RSSConfig['Link_ID'][1]   = 0;

  $RSSConfig['URLs'][2]      = 'http://irclove-kindergarten.blogspot.com/atom.xml';
  $RSSConfig['Commands'][2]  = '!KIGABLOG';
  $RSSConfig['Link_ID'][2]   = 0;

  $RSSConfig['URLs'][3]      = 'http://www.heise.de/newsticker/heise-atom.xml';
  $RSSConfig['Commands'][3]  = '!HEISE';
  $RSSConfig['Link_ID'][3]   = 0;

  $RSSConfig['URLs'][4]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/label/webcomix';
  $RSSConfig['Commands'][4]  = '!COMICS';
  $RSSConfig['Link_ID'][4]   = 0;

  $RSSConfig['URLs'][5]      = 'http://feeds.feedburner.com/G33ky';
  $RSSConfig['Commands'][5]  = '!GEEKY';
  $RSSConfig['Link_ID'][5]   = 0;	
  
  $RSSConfig['URLs'][6]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/label/kernel';
  $RSSConfig['Commands'][6]  = '!KERNEL';
  $RSSConfig['Link_ID'][6]   = 0;

  $RSSConfig['URLs'][7]      = 'http://www.heise.de/security/news/news-atom.xml';
  $RSSConfig['Commands'][7]  = '!HE-SEC';
  $RSSConfig['Link_ID'][7]   = 0;

  $RSSConfig['URLs'][8]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/label/security';
  $RSSConfig['Commands'][8]  = '!SECURITY';
  $RSSConfig['Link_ID'][8]   = 0;

  $RSSConfig['URLs'][9]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/label/torrents';
  $RSSConfig['Commands'][9]  = '!GERBT';
  $RSSConfig['Link_ID'][9]   = 0;

$RSSConfig['URLs'][10]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/label/axxo';
  $RSSConfig['Commands'][10]  = '!AXXO';
  $RSSConfig['Link_ID'][10]   = 0;

$RSSConfig['URLs'][11]      = 'http://www.google.com/reader/public/atom/user/00910410964970600802/label/quotes';
  $RSSConfig['Commands'][11]  = '!QDB';
  $RSSConfig['Link_ID'][11]   = 0;

$RSSConfig['URLs'][12]      = 'http://www.entwickler.com/rss/?version=atom0.3';
  $RSSConfig['Commands'][12]  = '!ENTWICKLER';
  $RSSConfig['Link_ID'][12]   = 0;




//  $RSSConfig['URLs'][8]      = 'http://www.jeckle.de/linuxKernelNews.rss';
//  $RSSConfig['Commands'][8]  = '!JECKLE';
//  $RSSConfig['Link_ID'][8]   = 0;        XML 0.9                          <link></link>
  
//  $RSSConfig['URLs'][9]      = 'http://n4rf.ath.cx/n4rf-linux.rss';
//  $RSSConfig['Commands'][9]  = '!N4RF';
//  $RSSConfig['Link_ID'][9]   = 0;       XML 2.0                    <link></link>

for($i=0; $i < sizeof($RSSConfig['URLs']); $i++)	
  {
    if(strtoupper($args[0]) == $RSSConfig['Commands'][$i])
    {
     if ($args[1]=='')$args[1]=3;
     if ($args[1]<=5)
     {
      rss($RSSConfig["Link_ID"][$i],$RSSConfig["URLs"][$i],$args[1]);
     }
     else
     {
      rss($RSSConfig["Link_ID"][$i],$RSSConfig["URLs"][$i],3);
      cmd_send(prep_text("FEHLER","Maximale Anzahl der angezeigten Elemente ist 5"));
     }
    }

  }
  
if(strtoupper($args[0]) == "!RSS")
{
$feeds = "";
for($i=0; $i < sizeof($RSSConfig['URLs']); $i++)	
{
$feeds = $feeds.$RSSConfig['Commands'][$i]." ";
}

cmd_send(prep_text("RSS-Feeds",$feeds));
cmd_send(prep_text("RSS-Feeds","Usage: <feed-command> <number of items>  OR !url <feed-command> to obtain the URL of the used Feed"));
}

//register commands 
if(strtoupper($args[0]) == "!COMMANDS")
{
	$COMMANDS=$COMMANDS.", [!RSS]";
}
if(strtoupper($args[0])=="!URL")
{
for($i=0; $i < sizeof($RSSConfig['URLs']);$i++)
    {
    if(strtoupper($args[1])==$RSSConfig['Commands'][$i])
	{
	cmd_send(prep_text("RSS-URL",$RSSConfig['URLs'][$i]));
	}
    }
}

//if(strtoupper($args[0]) == "!PROXY")
//{
//global $PROXY;
//cmd_send(prep_text("Proxy",'tcp://'.$PROXY['host'].':'.$PROXY['port']));
//}

  
  
  
  
  
  /*
  
  	if(strtoupper($args[0]) == '!RSS')
	{
	if($args[1]!="")
     {
         rss(1, $url=$args[1],$items=3);
     }
     else
     {
         rss(2, $url="http://www.google.com/reader/public/atom/user/00910410964970600802/state/com.google/broadcast",$items=3);
     }
  }
  
  
	if(strtoupper($args[0]) == '!RSS')
  {//!rss
            $url = "http://www.google.com/reader/public/atom/user/00910410964970600802/state/com.google/broadcast";
            if($args[1]!='')$url=$args[1];
            $file = $page = file_get_contents($url,'r');
            $xml =xmlize($file);
            $all = $xml["feed"]["#"]["entry"];

            for($i = 0; $i < 3;$i++)
            {
            $first = $all[$i];
            $link = $first["#"]["link"][1];
            $heading = $first["#"]["title"][0]["#"];
            cmd_send(prep_text($heading,$link["@"]["href"]));
            }
	}//!rss



	$people = $xml["people"]["#"]["person"];
	for($i = 0; $i < sizeof($people); $i++) {
		$person = $people[$i];
		$age 	= $person["@"]["age"];
		$name	= $person["#"]["name"][0]["#"];
		$job 	= $person["#"]["job"][0]["#"];
		print "$name - $age - $job<br>\n";
	}

people>
	<person age="29">
		<name>Fred Smith</name>
		<job>Webmaster</job>
	</person>
	<person age="31">
		<name>Patrick Jefferson</name>
		<job>Chef</job>
	</person>
</people>   */

?>

